<template>
	<view style="position: relative;">
		<u-navbar title=" " :autoBack="true" bgColor="transparent" leftIconColor="#fff" fixed></u-navbar>

		<image :src="poster" style="width: 100%;" mode="widthFix"></image>
		<view class=""
			style="position: absolute;bottom: 450rpx;left: 0;width: 100%;padding: 0 60rpx;box-sizing: border-box;">
			<u-button shape="circle" color="#d3b866" text="保存相册" @click="saveImage"></u-button>
		</view>
	</view>
</template>

<script>
	import {
		shareCreatePoster
	} from '@/common/api.js'
	export default {
		data() {
			return {
				poster: ""
			}
		},
		onLoad() {
			this.create()
		},
		methods: {
			create() {
				shareCreatePoster().then(res => {
					console.log('res', res);
					this.poster = res
				})
			},
			saveImage() {
				uni.showLoading({
					title: '保存中...'
				})
				uni.downloadFile({
					url: this.poster,
					success(res) {
						if (res) {
							console.log('下载成功', res)
							uni.hideLoading();
							uni.saveImageToPhotosAlbum({
								filePath: res.tempFilePath,
								success(res) {
									console.log(res);
								},
								fail(res) {
									console.log(res);
								},
							});
						}
					},
					fail: (err) => {
						if (err) {
							console.log('下载失败', err)
							uni.hideLoading();
						}
					}
				});
			}
		}
	}
</script>

<style>

</style>